<?xml version="1.0"?>
<rss version="2.0">
  <channel><title>poste.io upgrade</title><link>http://bill.welliver.org//space/smartos/poste.io upgrade</link><description>&lt;i class="ital"&gt;Note:&lt;/i&gt; Verified 3/10/2020&lt;p class="paragraph"/&gt;
Updating an LX zone from an updated docker image is pretty simple; if you want to preserve data you'll need to do so before-hand, or have pre-configured your zone to store things in a delegated dataset, which will be preserved across reprovisions. The only real trick is that the reprovision will remove the init script we added to mount the delegated dataset and lofs-mount any directories into the filesystem. So, we'll make sure we put that back in, after the reprovision but before the zone is started back up.&lt;p class="paragraph"/&gt;
This procedure also makes a backup of the zone just in case things go badly.&lt;p class="paragraph"/&gt;
&lt;i class="ital"&gt;Note:&lt;/i&gt; though this is presented in the form of a shell script, &lt;b class="bold"&gt;DO NOT&lt;/b&gt; run it as such, but rather consider each line individually. Otherwise you'll likely trash your zone.&lt;p class="paragraph"/&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
&lt;font color=brown&gt;# import the new version of the image we want to run&#xD;
&lt;/font&gt;imgadm &lt;b&gt;&lt;font color=darkblue&gt;import&lt;/font&gt;&lt;/b&gt; analogic/poste.io&#xD;
&lt;font color=brown&gt;# make note of the image uuid imported and set NEW_IMAGE to this value&#xD;
&lt;/font&gt;UUID=91854c5c-a285-6522-9da8-e38a04116fd6&#xD;
NEW_IMAGE=some_uuid&#xD;
BACKUP_LOCATION=/zones/images/smtp-data.zfs&#xD;
SNAPSHOT_NAME=begin&lt;p class="paragraph"/&gt;
&lt;font color=brown&gt;# stop the zone and make a copy of the zfs delegated setup script  &#xD;
&lt;/font&gt;vmadm stop ${UUID}&#xD;
cp /zones/${UUID}/root/etc/cont-init.d/01-init-zfs.sh /tmp&lt;p class="paragraph"/&gt;
&lt;font color=brown&gt;# this is not strictly necessary, but sometimes it's nice to have a backup.&#xD;
&lt;/font&gt;echo &lt;i&gt;&lt;font color=darkred&gt;"Backing up to $BACKUP_LOCATION..."&lt;/font&gt;&lt;/i&gt;&#xD;
zfs snap zones/${UUID}/data@${SNAPSHOT_NAME}&#xD;
zfs send -Recv zones/${UUID}/data@begin &amp;gt; $BACKUP_LOCATION&lt;p class="paragraph"/&gt;
echo &lt;i&gt;&lt;font color=darkred&gt;"Reprovisioning..."&lt;/font&gt;&lt;/i&gt;&#xD;
echo '{&lt;i&gt;&lt;font color=darkred&gt;"image_uuid"&lt;/font&gt;&lt;/i&gt;: &lt;i&gt;&lt;font color=darkred&gt;"${NEW_IMAGE}"&lt;/font&gt;&lt;/i&gt;}' | vmadm reprovision ${UUID}&lt;p class="paragraph"/&gt;
&lt;font color=brown&gt;# restore the zfs delegated dataset bootstrap and truncated directory setup &#xD;
&lt;/font&gt;&lt;font color=brown&gt;# scripts back into place. this is because they have to run the first time, every &#xD;
&lt;/font&gt;&lt;font color=brown&gt;# time and thus can't be installed from /data/_override (which is a feature that&#xD;
&lt;/font&gt;&lt;font color=brown&gt;# poste.io provides for making customizations to their image, and which is not&#xD;
&lt;/font&gt;&lt;font color=brown&gt;# a standard feature across docker images).&#xD;
&lt;/font&gt;&lt;font color=brown&gt;#&#xD;
&lt;/font&gt;&lt;font color=brown&gt;# alternatively, we could override the docker:cmd field and do something there&#xD;
&lt;/font&gt;&lt;font color=brown&gt;# or build a custom docker image.&#xD;
&lt;/font&gt;vmadm stop ${UUID}&#xD;
cp /tmp/0*.sh /zones/${UUID}/root/etc/cont-init.d/&lt;p class="paragraph"/&gt;
&lt;font color=brown&gt;#If, for some reason the container starts up immediately after provision, the zfs init script won't work as &#xD;
&lt;/font&gt;&lt;font color=brown&gt;#the /data directory will be present and non-empty. If this happens, move it out of the way and restart.&#xD;
&lt;/font&gt;&lt;font color=brown&gt;# then, zlogin and verify that the /data directory has the delegated dataset (with the local and _override directories)&#xD;
&lt;/font&gt;&#xD;
vmadm start ${UUID} &#xD;
&lt;font color=brown&gt;# to restart with ipf running we have to reboot.&#xD;
&lt;/font&gt;vmadm reboot ${UUID}&lt;p class="paragraph"/&gt;
&lt;font color=brown&gt;# restoring the delegated dataset is not necessary when we use reprovision, but is &#xD;
&lt;/font&gt;&lt;font color=brown&gt;# kept as an example of how to do it.&#xD;
&lt;/font&gt;zfs recv -F zones/${UUID}/data &amp;lt; ${BACKUP_LOCATION}&#xD;
zfs rollback zones/${UUID}/data@${SNAPSHOT_NAME}&#xD;
zfs destroy zones/${UUID}/data@${SNAPSHOT_NAME}&lt;p class="paragraph"/&gt;
rm ${BACKUP_LOCATION}&#xD;
&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;
</description><generator>Fins 0.9.7</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs></channel>
</rss>
